DESTDIR ?=
PREFIX ?=

PO_FILES = $(shell find target/po/bo_CN -type f -name "*.po")
MO_FILES = $(PO_FILES:.po=.mo)
TS_FILES = $(shell find target/ts/bo_CN -type f -name "*.ts")
QM_FILES = $(TS_FILES:.ts=.qm)

.PHONY: all clean install install-mo install-qm

$(MO_FILES): 
	python3 bin/fmt.py target/po/bo_CN/ 

target/ts/bo_CN/%.qm: target/ts/bo_CN/%.ts
	lconvert -i $< -o $@

all: $(MO_FILES) $(QM_FILES)

clean:
	rm -f $(MO_FILES) $(QM_FILES)

install-mo: $(MO_FILES)
	install -d $(DESTDIR)$(PREFIX)/share/locale/bo_CN/LC_MESSAGES/
	install -m 644 $(MO_FILES) $(DESTDIR)$(PREFIX)/share/locale/bo_CN/LC_MESSAGES/
	install -d $(DESTDIR)$(PREFIX)/share/locale-langpack/bo_CN/LC_MESSAGES/
	install -m 644 $(MO_FILES) $(DESTDIR)$(PREFIX)/share/locale-langpack/bo_CN/LC_MESSAGES/
	#install -d $(DESTDIR)$(PREFIX)/share/locale/bo_CN/LC_MESSAGES/
	#install -m 644 target/po/bo_CN/kconfigwidgets5.mo $(DESTDIR)$(PREFIX)/share/locale/bo_CN/LC_MESSAGES/
	#install -d $(DESTDIR)$(PREFIX)/share/locale/bo_CN/LC_MESSAGES/
	#install -m 644 target/po/bo_CN/kxmlgui5.mo $(DESTDIR)$(PREFIX)/share/locale/bo_CN/LC_MESSAGES/

install-qm: $(QM_FILES)
	install -d $(DESTDIR)$(PREFIX)/share/biometric-manager/i18n_qm/
	install -m 644 target/ts/bo_CN/biometric-manager_bo_CN.qm $(DESTDIR)$(PREFIX)/share/biometric-manager/i18n_qm/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-scanner/translations/
	install -m 644 target/ts/bo_CN/kylin-scanner_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-scanner/translations/kylin-scanner_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-notebook/
	install -m 644 target/ts/bo_CN/ukui-notebook_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-notebook/ukui-notebook_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-background-upgrade/kylin-background-upgrade_bo_CN.qm
	install -m 644 target/ts/bo_CN/kylin-background-upgrade_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-background-upgrade/kylin-background-upgrade_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/indicator-china-weather/translations/
	install -m 644 target/ts/bo_CN/indicator-china-weather_bo_CN.qm $(DESTDIR)$(PREFIX)/share/indicator-china-weather/translations/indicator-china-weather_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-calculator/translations/
	install -m 644 target/ts/bo_CN/kylin-calculator_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-calculator/translations/kylin-calculator_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/translations/
	install -m 644 target/ts/bo_CN/kylin-camera_bo_CN.qm $(DESTDIR)$(PREFIX)/share/translations/kylin-camera_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-recorder/translations/
	install -m 644 target/ts/bo_CN/kylin-recorder_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-recorder/translations/kylin-recorder_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-screenshot/translations/
	install -m 644 target/ts/bo_CN/kylin-screenshot_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-screenshot/translations/Internationalization_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-service-support/translations/
	install -m 644 target/ts/bo_CN/kylin-service-support_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-service-support/translations/kylin-service-support_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-software-properties/kylin-source-manager/translations/
	install -m 644 target/ts/bo_CN/kylin-software-properties-source-manager-interface_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-software-properties/kylin-source-manager/translations/source_manager_interface_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-photo-viewer/translations/
	install -m 644 target/ts/bo_CN/kylin-photo-viewer_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-photo-viewer/translations/kylin-photo-viewer_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-software-properties/service/translations/
	install -m 644 target/ts/bo_CN/kylin-software-properties_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-software-properties/service/translations/kylin-software-properties_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-user-guide/translations/
	install -m 644 target/ts/bo_CN/kylin-user-guide_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-user-guide/translations/kylin-user-guide_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-video/translations/
	install -m 644 target/ts/bo_CN/kylin-video-qtbase_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-video/translations/qtbase_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-video/translations/
	install -m 644 target/ts/bo_CN/kylin-video_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-video/translations/kylin-video_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/libpeony-qt/ 
	install -m 644 target/ts/bo_CN/libpeony-qt-box_bo_CN.qm $(DESTDIR)$(PREFIX)/share/libpeony-qt/qbox_bo_CN.qm 
	install -d $(DESTDIR)$(PREFIX)/share/libpeony-qt/
	install -m 644 target/ts/bo_CN/libpeony-qt_bo_CN.qm $(DESTDIR)$(PREFIX)/share/libpeony-qt/libpeony-qt_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/peony-qt-desktop/
	install -m 644 target/ts/bo_CN/peony-qt-desktop_bo_CN.qm $(DESTDIR)$(PREFIX)/share/peony-qt-desktop/peony-qt-desktop_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/peony-qt/
	install -m 644 target/ts/bo_CN/peony-qt_bo_CN.qm $(DESTDIR)$(PREFIX)/share/peony-qt/peony-qt_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/youker-assistant/translations/
	install -m 644 target/ts/bo_CN/kylin-assistant_bo_CN.qm $(DESTDIR)$(PREFIX)/share/youker-assistant/translations/kylin-assistant_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-biometric/i18n_qm/bioauth-bin/
	install -m 644 target/ts/bo_CN/ukui-biometric-bioauth-bin_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-biometric/i18n_qm/bioauth-bin/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-biometric/i18n_qm/polkit/
	install -m 644 target/ts/bo_CN/ukui-biometric-polkit_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-biometric/i18n_qm/polkit/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-biometric/i18n_qm/
	install -m 644 target/ts/bo_CN/ukui-biometric_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-biometric/i18n_qm/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-bluetooth/translations/
	install -m 644 target/ts/bo_CN/ukui-bluetooth_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-bluetooth/translations/ukui-bluetooth_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-clock/
	install -m 644 target/ts/bo_CN/ukui-clock_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-clock/ukui-clock_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui/
	install -m 644 target/ts/bo_CN/ukui-about_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui/ukui-about_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-media/translations/
	install -m 644 target/ts/bo_CN/ukui-media_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-media/translations/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-menu/translations/
	install -m 644 target/ts/bo_CN/ukui-menu_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-menu/translations/ukui-menu_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-greeter/translations/
	install -m 644 target/ts/bo_CN/ukui-greeter_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-greeter/translations/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-panel/panel/resources/
	install -m 644 target/ts/bo_CN/ukui-panel_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-panel/panel/resources/ukui-panel_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-power-manager/tray/translations/
	install -m 644 target/ts/bo_CN/ukui-power-manager-tray_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-power-manager/tray/translations/ukui-power-manager-tray_bo_CN.qm   
	install -d $(DESTDIR)$(PREFIX)/share/ukui-screensaver/i18n_qm/
	install -m 644 target/ts/bo_CN/ukui-screensaver_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-screensaver/i18n_qm/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-search/translations/
	install -m 644 target/ts/bo_CN/ukui-search_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-search/translations/bo_CN.qm 
	install -d $(DESTDIR)$(PREFIX)/share/ukui/translations/ukui-session-manager/
	install -m 644 target/ts/bo_CN/ukui-session-manager_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui/translations/ukui-session-manager/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-sidebar-clipboard/
	install -m 644 target/ts/bo_CN/ukui-sidebar-clipboard_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-sidebar-clipboard/ukui-sidebar-clipboard_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-sidebar-notification/
	install -m 644 target/ts/bo_CN/ukui-sidebar-notification_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-sidebar-notification/ukui-sidebar-notification_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-sidebar/
	install -m 644 target/ts/bo_CN/ukui-sidebar_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-sidebar/ukui-sidebar_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-time-shutdown/
	install -m 644 target/ts/bo_CN/ukui-time-shutdown_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-time-shutdown/time-shutdown_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-control-center/shell/res/i18n/
	install -m 644 target/ts/bo_CN/ukui-control-center_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-control-center/shell/res/i18n/bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-nm/translations/
	install -m 644 target/ts/bo_CN/kylin-nm_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-nm/translations/kylin-nm_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-music/translations/
	install -m 644 target/ts/bo_CN/kylin-music_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-music/translations/kylin-music_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-display-switch/translations/
	install -m 644 target/ts/bo_CN/kylin-display-switch_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-display-switch/translations/kylin-display-switch_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/kylin-os-installer/language/
	install -m 644 target/ts/bo_CN/kylin-os-installer_bo_CN.qm $(DESTDIR)$(PREFIX)/share/kylin-os-installer/language/kylin-os-installer_bo_CN.qm
	install -d $(DESTDIR)$(PREFIX)/share/ukui-system-monitor/translations/
	install -m 644 target/ts/bo_CN/ukui-system-monitor_bo_CN.qm $(DESTDIR)$(PREFIX)/share/ukui-system-monitor/translations/ukui-system-monitor_bo_CN.qm

install: install-mo install-qm
